;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;  SystemTypes
;  script file for MPW
;
;  This file should have any useful macros for the debugger.
;  Examples of this are structures for the register maps in 
;  the processors, the globals, and other data formats.
;
; REVISION HISTORY:
;		??/??/??	???	Creator and origin unknown
;		06/02/98	vmk	Added AlmGlobals and AlmGlobalsV30 aliases
;		07/12/99	kwk	Added hwrJerryPldShadow, radioGlobalsP,
;							dbgHalDispatchP, fatalAlertTemplateP,
;							and fatalAlertBtnWidth to GlobalsType.
;		01/27/99	kwk	Added CharPtr, LineInfoType, & FieldType
;		07/15/99	kwk	Added silkscreenInfoP to GlobalsType.
;		08/04/99	kwk	Added deferred termination globals to GlobalsType.
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; These MPW script lines will do most of the work of converting
;   a C Structure type to Debugger format
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;find 
;replace  -c  /([A-Za-z]+)2[ t]+([_a-zA-Z0-9[]-]+)1;/ "> 2 "1""
;find 
;replace -c  //// ""
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Basic Types
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
typedef UInt32 "KernelID"
typedef UInt32 "LocalID"
typedef Int16 	"Err"
typedef UInt8	@"Ptr"
typedef Ptr		"VoidPtr"
typedef UInt8  @"MemPtr"
typedef UInt8  @"UInt8Ptr"
typedef MemPtr	@"MemHandle"
typedef UInt32	@"UInt32Ptr"
typedef UInt16	@"UInt16Ptr"
typedef UInt8  "Boolean"
typedef Char @"CharPtr"
typedef UInt16	"WChar"


typedef struct "M68KExcTableType"
	> UInt32 				"initStack"
	> UInt32 				"initPC"
	> UInt32 				"busErr"
	> UInt32 				"addressErr"
	> UInt32 				"illegalInstr"
	> UInt32 				"divideByZero"
	> UInt32 				"chk"
	> UInt32 				"trap"
	> UInt32 				"privilege"
	> UInt32 				"trace"
	> UInt32 				"aTrap"
	> UInt32 				"fTrap"
	> UInt32 				"reserved12"
	> UInt32 				"coproc"
	> UInt32 				"formatErr"
	> UInt32 				"unitializedInt"
	> UInt32 				"reserved"[8] \-
	> UInt32 				"spuriousInt"
	> UInt32 				"autoVec1"
	> UInt32 				"autoVec2"
	> UInt32 				"autoVec3"
	> UInt32 				"autoVec4"
	> UInt32 				"autoVec5"
	> UInt32 				"autoVec6"
	> UInt32 				"autoVec7"
	> UInt32 				"trapN"[#16] \-
	> UInt32 				"unassigned"[#16] \-
	typeend
	
	
typedef struct "SysNVParamsType"
	> UInt32				"rtcHours"
	> UInt32				"rtcHourMinSecCopy"
	> UInt8					"swrLCDContrast"
	> UInt8					"swrLCDBrightnessValue"
	> Ptr					"splashScreenPtr"
	> Ptr					"hardResetScreenPtr"
	> UInt16				"localeLanguage"
	> UInt16				"localeCountry"
	typeend
	
	
typedef struct "StorageHeaderType"
	> UInt32 				"signature"
	> UInt16 				"version"
	> UInt16 				"flags"
	> Char 					"name"[#32] 
	> UInt32 				"creationDate"
	> UInt32 				"backupDate"
	> UInt32 				"heapListOffset"
	> UInt32 				"initCodeOffset0"
	> UInt32 				"initCodeOffset1"
	> LocalID 				"databaseDirID"
	> UInt32	 			"rsvSpace"
	> UInt32	 			"dynHeapSpace"
	> UInt32	 			"firstRAMBlockSize"
	> SysNVParamsType	 	"nvParams"
	> UInt8 				"reserved"[#154] \-
	typeend
typedef StorageHeaderType 	@"StorageHeaderPtr"
	


typedef struct "SysBatteryDataType"
	> UInt16	"sysBattDataStructVersion"
	> UInt16	"sysBattMildWrngVoltage"
	> UInt16	"sysBattSevereWrngVoltage"
	> UInt16	"sysBattMildWrngPercent"
	> UInt16	"sysBattSevereWrngPercent"
	> UInt16	"sysBattShutdownEnVoltage"
	> UInt16	"sysBattShutdownDisVoltage"
	> UInt16	"sysBattMinIRVoltage"
	> UInt32	"sysBattMildWrngTimeout"
	> UInt32	"sysBattSevereWrngTimeout"
	> UInt16	"sysBattCritWarnOffDays"
	> UInt32 "sysBattCritWarnOnTicks"
	> UInt16	"sysBattStepsPerVolt"
	> Int16	"sysBattVoltageStepOffset"
	> UInt32	"sysBattReserved1"
	> UInt32	"sysBattReserved2"
	> UInt16	"sysBattVoltageCurve"[#11]
	typeend
	
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Generic Serial Manager defininitions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

typedef struct "SerSettingsType"
	> UInt32 				"baudRate"
	> UInt32 				"flags"		\%
	> Int32 					"ctsTimeout"
	typeend


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 68328 Serial Manager defininitions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	
typedef struct "SerGlobalsType"
	> UInt16 				"openCount"
	> Int16					"port"
	> SerSettingsType	 	"settings"
	> UInt16 				"lineErrors"
	
	> UInt16 				"qStart"
	> UInt16 				"qEnd"
	> UInt16 				"qSize"
	> MemPtr					"qData"
	> MemPtr					"defQData"
	
	> MemPtr					"wakeupHandler"
	> UInt32					"wakeupRefcon"
	> UInt16 				"smSignalSize"
	> Int32 					"smID"
	> UInt32 				"lastRcvTicks"
	
	> UInt16					"numReceived"
	> UInt16					"lastErrorStatus"
	> UInt16					"numRcvErrors"
	typeend
typedef SerGlobalsType	@"SerGlobalsPtr"



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 68681 Serial Manager defininitions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

typedef struct "M681DuartRead"
>		UInt8		"mra" \%
>		UInt8	"u0" \-
>		UInt8		"sra" \%
>		UInt8	"u2" \-
>		UInt8	"doNotAccess1"	\-
>		UInt8	"u4" \-
>		UInt8		"rba" \%
>		UInt8	"u6" \-
>		UInt8		"ipcr" \%
>		UInt8	"u8" \-
>		UInt8		"isr" \%
>		UInt8	"uA" \-
>		UInt8		"cur" \%
>		UInt8	"uC" \-
>		UInt8		"clr" \%
>		UInt8	"uE" \-
>		UInt8		"mrb" \%
>		UInt8	"u10" \-
>		UInt8		"srb" \%
>		UInt8	"u12" \-
>		UInt8		"doNotAccess2"	\-
>		UInt8	"u14" \-
>		UInt8		"rbb" \%
>		UInt8	"u16" \-
>		UInt8		"ivr" \%
>		UInt8	"u18" \-
>		UInt8		"ipr" \%
>		UInt8	"u1A" \-
>		UInt8		"startCtr"
>		UInt8	"u1C" \-
>		UInt8		"stopCtr"
>		UInt8	"u1E" \-
	typeend
		
typedef struct "M681DuartWrite"
>		UInt8		"mra"
>		UInt8	"u0"
>		UInt8		"csra"
>		UInt8	"u2"
>		UInt8		"cra"
>		UInt8	"u4"
>		UInt8		"tba"
>		UInt8	"u6"
>		UInt8		"acr" 
>		UInt8	"u8"
>		UInt8		"imr"
>		UInt8	"uA"
>		UInt8		"ctur"
>		UInt8	"uC"
>		UInt8		"ctlr"
>		UInt8	"uE"
>		UInt8		"mrb"
>		UInt8	"u10"
>		UInt8		"csrb"
>		UInt8	"u12"
>		UInt8		"crb"
>		UInt8	"u14"
>		UInt8		"tbb"
>		UInt8	"u16"
>		UInt8		"ivr"
>		UInt8	"u18"
>		UInt8		"opcr"
>		UInt8	"u1A"
>		UInt8		"opSet"
>		UInt8	"u1C"
>		UInt8		"opReset"
>		UInt8	"u1E"
	typeend


typedef struct "Ser681DebugInfoType"
	> UInt16 "lineErrorCount"
	> UInt16 "numReceived"
	> UInt16 "numSent"
	> UInt8 "lastReceived"
	> UInt8 "lastErrorStatus"	\%
	> UInt16 "hwOverrunCount"
	> UInt16 "parityErrorCount"
	> UInt16 "framingErrorCount"
	typeend
	
typedef Ser681DebugInfoType	@"Ser681DebugInfoPtr";



typedef struct "Ser681GlobalsType"
	> UInt32 "openSignature"
													
	> UInt16 "openCount"
	> Int16 "port"
	> SerSettingsType "settings"
	> UInt16 "lineErrors"
	
	> VoidPtr "chanP"
	
	> UInt16 "qStart"
	> UInt16 "qEnd"
	> UInt16 "qSize"
	> MemPtr "qData"
	> MemPtr "defQData"
	
	
	> UInt16 "smSignalSize"
	> UInt32 "smID"

	> UInt32 "lastRcvTicks"

	> UInt8 "currentIMR"
	> MemPtr "oldIRQ3P"
	
	> Ser681DebugInfoType "debugInfo"
	
	typeend
	
typedef Ser681GlobalsType	@"Ser681GlobalsPtr"

var "hwrDuartBase"		$10E00000



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Srm (Bond) manager globals
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

typedef struct "DrvrRcvQType"
	> VoidPtr		"rcvQ"
	> VoidPtr		"qWriteByte"
	> VoidPtr		"qWriteBlock"
	> VoidPtr		"qGetSize"
	> VoidPtr		"qGetSpace"
	> VoidPtr		"qSignalCheck"
	typeend
typedef DrvrRcvQType	@"DrvrHWRcvQPtr"



typedef struct "DrvrInfoType"
	> UInt32          "drvrID"
	> UInt32          "drvrVersion" 
								 
	> UInt32          "maxBaudRate" 
	> UInt32          "handshakeThreshold" 
											 
	> UInt32          "portFlags"
	> CharPtr         "portDesc" 
								 
	> UInt8			  "irqType"	 

	> UInt8           "multipleEnumerations"

	> UInt32          "dbCreator"
	typeend

typedef struct "SrmRcvQType"
	> UInt32          "qStart"	
	> UInt32          "qEnd"		
	> UInt32          "qSize"		
	> UInt8Ptr          "qData"		
	> VoidPtr			"qPort"		
	typeend


typedef struct "SrmOpenPortType"
	> VoidPtr			"drvOpenProc"
	> VoidPtr			"drvCloseProc"
	> VoidPtr			"drvControlProc"
	> VoidPtr			"drvStatusProc"
	> VoidPtr			"drvReadProc"
	> VoidPtr			"drvWriteProc"
	> VoidPtr			"drvOpenV4Proc"

	> UInt16          "portNo"
								

	> Int32           "baudRate"
	> UInt32          "settingsFlags"
	> Int32           "ctsTimeout" 

	> VoidPtr         "wakeupHandler" 
	> UInt32          "wakeupRefcon" 

	> SrmRcvQType     "rcvQueue" 
	> UInt8Ptr        "defQData" 
	> DrvrHWRcvQPtr   "drvrQueueP" 

	> UInt32          "lastRcvTicks" 
	> UInt16          "lineErrors" 

	> UInt16          "smSignalSize" 
	> UInt32          "smID"		 

	> Boolean         "irdaMode" 

	> Boolean         "backgroundPort" 
	> VoidPtr		  "nextPort" 

	> UInt16          "numReceived" 
								 
	> UInt16          "lastErrorStatus" 
	> UInt16          "numRcvErrors"
	typeend
typedef SrmOpenPortType	@"SrmOpenPortPtr"



typedef struct "SrmPortInfoType"
	> UInt16          "cardNo"	 								 
	> LocalID         "dbIDNo"	 								 
	> MemHandle       "drvrCodeH" 								 
	> VoidPtr         "oldIntHandler" 									 
	> VoidPtr         "drvrData"	 
	> DrvrInfoType    "drvrInfo" 
	> SrmOpenPortPtr  "thePortP" 
	typeend


typedef struct "SrmGlobalsType"
	> UInt16          "portCount"
	> UInt32          "cradlePort" 								 
	> UInt32          "irdaPort"
	> UInt32		  "consolePort"
								 
	> SrmPortInfoType "portInfo"[#11]	 
	typeend 



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Serial Link Manager defininitions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

typedef struct "SlkSocketListenType"
	> MemPtr					"listenerP"
	> MemPtr					"headerBufferP"
	> MemPtr					"bodyBufferP"
	> UInt32					"bodyBufferSize"
	typeend
	
typedef SlkSocketListenType  @"SlkSocketListenPtr"


typedef struct "SlkRefInfoType"
	> UInt16				"refNum"
	> Int8					"destID"
	> UInt8					"padding"
	typeend


var 	"slkMaxSockets"		#6
typedef struct "SlkGlobalsType"
	> UInt16		  		"openCount"
	> UInt16				"socketRefNum"[slkMaxSockets]
	> Boolean				"socketOpen"[slkMaxSockets]
	> SlkSocketListenPtr	"socketListenP"[slkMaxSockets]
	> UInt16				"socketTimeout"[slkMaxSockets]
	
	> SlkRefInfoType		"refInfo"[slkMaxSockets]
	
	> UInt8					"transId"
	> UInt8					"padding"
	> Int32					"xmitSemaphoreID"
	> UInt16				"numReceived"

	> Boolean				"socketWantsBuffering"[slkMaxSockets]
	> MemPtr				"sendBufferP"
	> UInt16				"sendBufferSize"
	typeend

typedef SlkGlobalsType  @"SlkGlobalsPtr"
	
	
typedef struct "M68KRegsType"
	> UInt32					"d"[8]
	> UInt32					"a"[7]
	> UInt32					"usp"
	> UInt32					"ssp"
	> UInt32					"pc"
	> UInt16					"sr"
	typeend
	
typedef struct "BreakpointType"
	> MemPtr					"addr"
	> Boolean				"enabled"
	> Boolean				"installed"
	typeend
	
	
typedef struct "DbgGlobalsType"
	> M68KRegsType			"reg"
	> Boolean				"romBP"
	> Boolean				"stepOverBP"
	> BreakpointType		"bp"[#6]
	> UInt16					"bpOpcode"[#6]
	> UInt16					"trapBreak"[#5]
	> UInt16					"trapParam"[#5]
	> UInt32					"oldDispatcher"
	> Boolean				"breakingOnATrap"
	> Boolean				"ignoreDbgBreaks"
	> Boolean				"commOpened"
	> Boolean				"stepSpy"
	> UInt32					"ssAddr"
	> UInt32					"ssValue"
	> UInt16					"excType"
	> UInt8					"reEntered"
	> UInt8					"firstEntrance"
	> UInt8					"serGlobals"[#64] \-
	> UInt32					"busErrStack"[2] 
	> UInt8					"stack"[380] \-
	> UInt16					"stackEnd"
	typeend
	
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Generic defininitions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

typedef struct "PointType"
	> Int16					"x"
	> Int16					"y"
	typeend
	
	
typedef struct "RectangleType"
	> PointType				"topLeft"
	> PointType				"extent"
	typeend
	
typedef struct "PenQueueType"
	> Int16 					"start"
	> Int16 					"end"
	> Int16 					"size"
	> UInt16 				"strokeCount"
	> Boolean 				"returnedPenDown"
	> PointType 			"addLast"
	> Int16  				"addStrokeStart"
	> UInt16  				"strokesRemoved"
	> Int16  				"rmvStrokeStage"
	> PointType  			"rmvLast"
	> PointType  			"rmvStartPt"
	> UInt8		 			"data"
	typeend
typedef PenQueueType 	@"PenQueuePtr"
	
typedef struct "KeyQueueType"
	> UInt16					"start"
	> UInt16					"end"
	> UInt16					"size"
	> UInt8					"data"
	typeend
typedef KeyQueueType 	@"KeyQueuePtr"
	
	
typedef struct "SysEvtMgrGlobalsType"
	> Boolean 				"sendNullEvent"
	> Boolean  				"enableGraffiti"
	> Boolean  				"enableSoftKeys"
	> Boolean  				"removeTopStroke"
	> PenQueuePtr  		"penQP"
	> UInt16  				"penQStrokesRemoved"
	> KeyQueuePtr  		"keyQP"
	> RectangleType  		"writingR"
	> UInt16  				"appAreaBottom"
	> UInt16  				"penX"
	> UInt16  				"penY"
	> Boolean  				"penDown"
	> Boolean  				"displayingBatteryAlert"
	> UInt16  				"lastPenX"
	> UInt16  				"lastPenY"
	> Boolean  				"lastPenDown"
	> Boolean  				"needRemoteScrUpdate"
	> UInt8 					"gremlinsFlags"
	> Boolean 				"idle"
	> Boolean 				"gotUserEvent"
	typeend														
	

typedef struct "RecordEntryType" 
	> LocalID 				"localChunkID"
	> UInt8 					"attributes"
	> UInt8					"uniqueID"[3]			
	typeend
typedef RecordEntryType	@"RecordEntryPtr"

typedef struct "RsrcEntryType" 
	> UInt32 				"type"
	> UInt16 				"id"
	> UInt16 				"size"
	> LocalID 				"localChunkID"
	typeend
typedef RsrcEntryType	@"RsrcEntryPtr"

typedef struct "RecordListType" 
	> LocalID 				"nextRecordListID"
	> UInt16 				"numRecords"
	> UInt16 				"firstEntry"
	typeend
typedef RecordListType	@"RecordListPtr"



typedef struct "DatabaseHdrType" 
	> Char					"name"[20]		\-			
	> UInt16 				"attributes"
	> UInt16 				"version"

	> UInt32 				"creationDate"
	> UInt32 				"modificationDate"
	> UInt32 				"lastBackupDate"
	> UInt32 				"modificationNumber"

	> LocalID 				"appInfoID"
	> LocalID 				"sortInfoID"

	> UInt32 				"type"
	> UInt32 				"creator"

	> UInt32 				"uniqueIDSeed"

	> RecordListType 		"recordList"
	typeend

typedef DatabaseHdrType	@"DatabaseHdrPtr"
typedef DatabaseHdrPtr	@"DatabaseHdrHand"


typedef struct  "DmOpenInfoType" 
	> MemPtr	 				"next"
	> UInt16 				"openCount"
	> UInt32					"ownerTaskID"
	> UInt16 				"exclusive,writeAccess,resDB"
	> LocalID 				"hdrID"
	> DatabaseHdrHand 	"hdrH"
	> DatabaseHdrPtr	 	"hdrP"
	> UInt16 				"cardNo"
	> UInt16 				"numRecords"
	> RecordEntryPtr 		"recordP"
	> RsrcEntryPtr 		"resourceP"
	> MemPtr					"hdrMasterP"
	> UInt16 				"numHandles"
	> MemPtr					@"handleTableP"				
	typeend
typedef DmOpenInfoType	@"DmOpenInfoPtr"

typedef struct "DmAccessType"
	> DmAccessType			@"next"
	> UInt16					"mode"
	> DmOpenInfoPtr		"openP"
	> UInt32					"savedModNum"
	typeend
typedef DmAccessType		@"DmAccessPtr"

typedef struct "DatabaseHdrTypeV549" 
	> Char					"name"[#32]
	> UInt16 				"attributes"
	> UInt16 				"version"

	> UInt32 				"creationDate"
	> UInt32 				"modificationDate"
	> UInt32 				"lastBackupDate"
	> UInt32 				"modificationNumber"

	> LocalID 				"appInfoID"
	> LocalID 				"sortInfoID"

	> UInt32 				"type"
	> UInt32 				"creator"

	> UInt32 				"uniqueIDSeed"

	> RecordListType 		"recordList"
	typeend

typedef DatabaseHdrTypeV549	@"DatabaseHdrPtrV549"
typedef DatabaseHdrPtrV549	@"DatabaseHdrHandV549"


typedef struct  "DmOpenInfoTypeV549" 
	> MemPtr	 				"next"
    > KernelID                  "ownerTaskID"
    > MemHandle                 "hdrH"
    > DatabaseHdrPtrV549        "hdrP"
    > MemPtr                    "hdrMasterP"
    > MemPtr                    @"handleTableP"
	> UInt16 				    "openCount"
    > UInt16                    "numRecords"
    > UInt16                    "exclusive,writeAccess,resDB,ioMapped,everOpenedForWrite"
    > UInt16                    "padding1"
    > MemPtr                    "loadedDBP"
	typeend
typedef DmOpenInfoTypeV549	@"DmOpenInfoPtrV549"

typedef struct "DmAccessTypeV549"
	> DmAccessTypeV549		@"next"
	> UInt16				 "mode"
    > UInt16                 "padding1"
	> DmOpenInfoPtrV549      "openP" 
	> UInt32		   		 "savedModNum"
    > UInt8                  "openType"
    > UInt8                  "reserved"
	typeend
typedef DmAccessTypeV549     @"DmAccessPtrV549"
typedef DmAccessPtrV549      "DmOpenRef"



var 	"penNumSamples"			#5
typedef struct "PenGlobalsType"
	> Boolean				"calibrated"
	> Boolean				"filler"
	> UInt16					"xOffset"
	> UInt16					"yOffset"
	> UInt16					"xScale"
	> UInt16					"yScale"
	> PointType				"sample"[penNumSamples]
	> UInt16					"delay"
	> UInt16					"maxDDZ"
	> UInt16					"maxSlop"
	> UInt16					"maxEndBlip"
	typeend
typedef PenGlobalsType	@"PenGlobalsPtr"


typedef struct "KeyGlobalsType"
	> UInt32					"lastKeyTicks"
	> UInt8					"keyStateV30"
	> UInt8					"keyStateMaskV30"
	> UInt8					"keyUpCount"
	> UInt8					"initDelay"
	> UInt8					"period"
	> Boolean				"queueAhead"
	> UInt32					"turnOnTicks"
	> UInt32					"doubleTapTicks"
	> UInt16					"doubleTapDelay"
	> UInt8					"doubleTapStateV30"
	> UInt8					"unused"
	> UInt8					"usedPortDBits"
	> UInt8					"antKeyPendCount"
	> UInt32					"keyState"
	> UInt32					"keyStateMask"
	> UInt32					"doubleTapState"
	typeend
typedef KeyGlobalsType	@"KeyGlobalsPtr"


typedef struct "TimGlobalsType"
	> UInt32					"rtcHours"
	> UInt32					"alarmSeconds"
	> Boolean				"rtcBugWorkaround"
	> Boolean				"rtcBugAsleep"
	> UInt32					"rtcBugAlarm"
	> UInt32					"rtcBugSeconds"
	> UInt32					"rtcBugLastSeconds"
	typeend
typedef TimGlobalsType	@"TimGlobalsPtr"


; An entry in the alarm table in PalmOS v1.0 - 3.0
typedef struct "AlmEntryTypeV30"
	>	UInt32				"ref"				; alarm reference value passed by caller;

	>	UInt32				"alarmSeconds"	; alarm date/time in seconds since 1/1/1904;
													; a value of 0 indicates unused entry;
		
	>	LocalID				"dbID"			; creator app database ID;

	>	UInt16				"flags"	\%

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;; represented by "flags"
	;	UInt16				cardNo : 1;		; creator app card number;
	;	
	;	UInt16				quiet : 1;		; 1 indicates that the caller wants
	;											; to be quietly notified when the alarm
	;											; goes off without all the alarm bells
	;											; and whistles;
	;
	;	UInt16				triggered : 1;	; 1 indicates the alarm has been triggered;
	;											
	;	UInt16				notified : 1;	; 1 indicates we notified the caller that
	;											; the alarm went off;
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	typeend


; An entry in the alarm table in current PalmOS
typedef struct "AlmEntryType"
	>	UInt32				"ref"				; alarm reference value passed by caller;

	>	UInt32				"alarmSeconds"	; alarm date/time in seconds since 1/1/1904;
													; a value of 0 indicates unused entry;
		
	>	LocalID				"dbID"			; creator app database ID
	>	UInt16				"cardNo"			; creator app card number

	>	UInt16				"flags"	\%

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;; represented by "flags"
	;	UInt16			quiet : 1;		; 1 indicates that the caller wants
	;											; to be quietly notified when the alarm
	;											; goes off without all the alarm bells
	;											; and whistles;
	;
	;	UInt16			triggered : 1;	; 1 indicates the alarm has been triggered;
	;											
	;	UInt16			notified : 1;	; 1 indicates we notified the caller that
	;											; the alarm went off;
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	typeend


; The alarm table
typedef struct "AlmTableType"
	> Int16				"numEntries"	; Number of entries in alarm Table;
		
												; List of alarm entries;
												; This is a variable size field which
												; ***MUST BE LAST***
	> AlmEntryType		"list"[1]	\-	; 0 or more entries
	typeend

typedef AlmTableType@		"AlmTablePtr"
typedef AlmTablePtr@			"AlmTableHandle"


; This was the AlmGlobalsType structure in PalmOS v1.0 - 3.0
typedef struct "AlmGlobalsTypeV30"
	>	AlmTableHandle	"tableH"			; alarm table handle;

	>	UInt32				"lastSoundSeconds"
												; alarm seconds of the last alarm for
												; which an alarm was sounded;
	>	UInt16				"displaying_triggered"	\%

	;;;;;;;;;;;;;;;;;;;;; represented by flags
	;	UInt16				displaying : 1;; 1 indicates we're blocked waiting for
	;											; some app to finish displaying an alarm
	;											; dialog box; set and cleared by
	;											; AlmDisplayNextAlarm();
	;											
	;	UInt16			triggered : 1;	; 1 indicates an alarm was triggered; this
	;											; field is set by the AlmAlarmCallback() and
	;											; is checked and cleared by AlmDisplayAlarm();
	;;;;;;;;;;;;;;;;;;;;;

	>	UInt8				"disableCount"	; if this value is greater than zero, Alarm
												; notifications are disabled (see AlmEnableNotification);
	typeend

; This is the current AlmGlobalsType
typedef struct "AlmGlobalsType"
	> MemHandle				"tableH"
	> UInt32					"lastSoundSeconds"
	> UInt16					"displaying_triggered"	\%
	> UInt8					"disableCount"
	> UInt8					"filler"
	> UInt32					"resSemID"
	typeend
typedef AlmGlobalsType	@"AlmGlobalsPtr"


typedef struct "SysAppInfoType"
	> Int16					"cmd"
	> MemPtr					"cmdPBP"
	> UInt16					"launchFlags"
	
	> Int32					"taskID"
	> MemHandle				"codeH"
	> MemPtr					"dbP"
	> MemPtr					"stackP"
	> MemPtr					"globalsChunkP"

	> UInt16					"memOwnerID"
	> MemPtr					"dmAccessP"
	> Int16					"dmLastErr"
	> MemPtr					"errExceptionP"

	> MemPtr					"a5Ptr"
	> MemPtr					"stackEndP"
	> MemPtr					"globalEndP"
	> MemPtr					"rootP"
	> MemPtr					"extraP"
	typeend
typedef SysAppInfoType  @"SysAppInfoPtr"


typedef struct "StorageHeaderType"
	> UInt32					"signature"
	> UInt16					"version"
	> UInt16					"flags"
	> UInt8					"name"[#32]
	> UInt32					"creationDate"
	> UInt32					"backupDate"
	> UInt32					"heapListOffset"
	> UInt32					"initCodeOffset"
	> LocalID				"databaseDirID"
	> UInt32					"rsvSpace"
	> UInt32					"dynHeapSpace"
	> UInt8					"reserved"[#184] \-
	> UInt32					"crc"
	typeend
typedef StorageHeaderType	@"StorageHeaderPtr"

typedef struct "CardInfoType"
	> UInt8Ptr					"baseP"
	> UInt32					"size"
	> UInt32					"firstRAMBlockSize"
	> UInt32					"targetROMShift"
	> UInt32					"cardHeaderOffset"
	> UInt32					"rsvSpace"
	> UInt32					"dynHeapSpace"
	> StorageHeaderPtr			"ramStoreP"
	> UInt16					"numRAMHeaps"
	> UInt32Ptr					"ramHeapOffsetsP"
	> UInt16					"numROMHeaps"
	> UInt32Ptr					"romHeapOffsetsP"
	> UInt32 					"cardOffsetMask"
	typeend
typedef CardInfoType		@"CardInfoPtr"

typedef struct "CardHeaderType"
	> UInt32					"initStack"
	> UInt32					"resetVector"
	> UInt32					"signature"
	> UInt16					"hdrVersion"
	> UInt16					"flags"
	> UInt8					"name"[#32]
	> UInt8					"manuf"[#32]
	> UInt16					"version"
	> UInt32					"creationDate"
	> UInt16					"numRAMBlocks"
	> UInt32					"blockListOffset"
	
	> UInt32					"readWriteParmsOffset"
	> UInt32					"readWriteParmsSize"
	> UInt32					"readOnlyParmsOffset"
	> UInt32					"bigROMOffset"
	> UInt32					"checksumBytes"
	> UInt16					"checksumValue"

	> UInt32					"readWriteWorkingOffset"
	> UInt32					"readWriteWorkingSize"

	> UInt32					"halCodeOffset"

	> UInt8					"reserved"[#130] \-
	typeend
typedef CardHeaderType 	@"CardHeaderPtr"

typedef struct "SysLibTblEntryType"
	> MemPtr					@"dispatchTblP"
	> MemPtr					"globalsP"
	> LocalID				"dbID"
	> MemPtr					"codeRscH"
	typeend
typedef SysLibTblEntryType @"SysLibTblEntryPtr"

typedef struct "GraphicStateTypeV20"
	> UInt8					"grafMode"
	> Boolean				"patternMode"
	> Boolean				"pattern"
	> UInt16					"customPtn"[4]
	> UInt8					"fontId"
	> MemPtr					"font"
	> UInt8					"underlineMode"
	typeend
	
typedef struct "RGBColorType"
	> UInt8					"index"
	> UInt8					"r"
	> UInt8					"g"
	> UInt8					"b"
	typeend

typedef struct "ColorTableType"
	> UInt16					"numEntries"
	> RGBColorType			"entry"[1]
	typeend
typedef ColorTableType @"ColorTablePtr"

typedef struct "GraphicStateType"
	> UInt8					"grafMode"
	> Boolean				"patternMode"
	> Boolean				"pattern"
	> UInt16					"customPtn"[4]
	> UInt8					"fontId"
	> MemPtr					"font"
	> UInt8					"underlineMode"
	> RGBColorType			"foreColor"
	> RGBColorType			"backColor"
	typeend
typedef GraphicStateType @"GraphicStatePtr"
	

typedef struct "AbsRectType"
	> Int16					"left"
	> Int16					"top"
	> Int16					"right"
	> Int16					"bottom"
	typeend
	
typedef UInt16 "CustomPatternType"[4]


typedef struct "ScrGlobalsTypeV20"
	> UInt16 				"width"
	> UInt16 				"height"
	> UInt16 				"rowBytes"
	> MemPtr					"baseAddr"
	> CustomPatternType	"grayPat"
	> Boolean 				"doDrawNotify"
	> AbsRectType 			"updateR"
	> Int32 					"lastUpdate"
	typeend
typedef ScrGlobalsTypeV20	@"ScrGlobalsPtrV20"

;***********************************************
;* Old Pre-3.5 GDevice type - Graphics version 2
;***********************************************
typedef struct "GDeviceTypeV2"
	> MemPtr					"baseAddr"
	> UInt16					"width"
	> UInt16					"height"
	> UInt16					"rowBytes"
	> UInt8					"pixelSize"
	> UInt8					"version"
	> UInt16					"flags"
	> ColorTablePtr		"cTableP"
	typeend
typedef GDeviceTypeV2 @"GDeviceV2Ptr"

;**************************************************
;* The new Graphics Version 3 GDeviceType structure
;**************************************************
typedef struct "GDeviceType"
	> MemPtr					"baseAddr"
	> UInt16					"width"
	> UInt16					"height"
	> UInt16					"rowBytes"
	> UInt8					"pixelSize"
	> UInt8					"version"
	> UInt16					"flags"
	> UInt16					"forePixels"
	> UInt16					"backPixels"
	> UInt16					"textPixels"
	> ColorTablePtr		"cTableP"
	typeend
typedef GDeviceType @"GDevicePtr"

typedef	UInt8	"WinDrawOperation"
typedef	UInt8 "PatternType"
typedef  UInt8	"UnderlineModeType"
typedef	UInt8	"FontID"
typedef	MemPtr"FontPtr"
typedef UInt16 "CustomPatternType" [4]
typedef UInt8	"IndexedColorType"

typedef struct "DrawStateType"
	> WinDrawOperation	"transferMode"
	> PatternType			"pattern"
	> UnderlineModeType	"underlineMode"
	> FontID					"fontId"
	> FontPtr				"font"
	> CustomPatternType	"patternData"
	> IndexedColorType	"foreColor"
	> IndexedColorType	"backColor"
	> IndexedColorType	"textColor"
	> UInt8				"reserved"
	> RGBColorType		"foreColorRGB"
	> RGBColorType		"backColorRGB"
	> RGBColorType		"textColorRGB"
	typeend
typedef DrawStateType @"DrawStatePtr"


typedef struct "GraphicStateType"
	> DrawStatePtr			"drawStateP"
	> DrawStatePtr			"drawStateStackP"
	> Int16					"drawStateIndex"
	> UInt16				"screenLockCount"
	typeend
typedef GraphicStateType @"GraphicStatePtr"



typedef struct "BitmapType"
	> UInt16  				"width"
	> UInt16  				"height"
	> UInt16  				"rowBytes"
	> UInt16					"flags"
	> UInt8					"pixelSize"
	> UInt8					"version"
	> UInt16	 				"nextDepthOffset"
	> UInt8					"transparentIndex"
	> UInt8					"compressionType"
	> UInt16	 				"reserved"
	typeend
	
typedef BitmapType @"BitmapPtr"

typedef struct "ColorTableType"
	> UInt16					"numEntries"
	> RGBColorType			"entries"[2]
typeend

typedef struct "ColorTableType4"
	> UInt16					"numEntries"
	> RGBColorType			"entries"[4]
typeend


typedef struct "ColorTableType16"
	> UInt16					"numEntries"
	> RGBColorType			"entries"[16]
typeend


typedef struct "ColorTableType256"
	> UInt16					"numEntries"
	> RGBColorType			"entries"[#256]
typeend


typedef struct "ColorTableType"
	> UInt16					"numEntries"
	> RGBColorType			"entries"[2]
typeend


typedef struct "BitmapDirectInfoType"
	> UInt8					"redBits"
	> UInt8					"greenBits"
	> UInt8					"blueBits"
	> UInt8					"reserved"
	> RGBColorType			"transparentColor"
typeend

typedef struct "ScrGlobalsType"
	> BitmapType			"gBitmap"
	> ColorTableType256		"gColorTable" \-
	> BitmapDirectInfoType	"directInfo"
	> MemPtr				"baseAddr"
	> DrawStateType		"gDrawState"
	> CustomPatternType		"grayPat"
	> Boolean				"doDrawNotify"
	> Boolean				"clutDirty"
	> AbsRectType			"updateR"
	> Int32					"lastUpdate"
	> UInt16				"expSrcSize"
	> UInt8					@"expSrcP"
	> UInt8					@"colorTranslateP" [4]
	typeend
typedef ScrGlobalsType	@"ScrGlobalsPtr"



typedef struct "ClipboardItem"
	> MemPtr					"item"
	> UInt16					"length"
	typeend
	
typedef struct "FieldUndoType"
	> UInt8					"mode"
	> UInt16					"start"
	> UInt16					"end"
	> UInt16					"bufferLen"
	> MemPtr					"buffer"
	typeend
	
typedef struct "WindowType"
	> UInt16					"displayWidthV20"
	> UInt16					"displayHeightV20"
	> MemPtr					"displayAddrV20"
	> UInt16					"windowFlags"
	> RectangleType				"windowBounds"
	> AbsRectType				"clipplingBounds"
	> BitmapPtr					"bitmapP"
	> UInt16					"frameType"
	> DrawStatePtr				"drawStateP"
	> MemPtr					"nextWindow"
	typeend
typedef WindowType @"WinPtr"
typedef WindowType @"WinHandle"

typedef struct "FormType31"
	> WindowType			"window"
	> UInt16					"formId"
	> UInt16					"attr"
	> WinPtr					"bitsBehindForm"
	> MemPtr					"handler"
	> UInt16					"focus"
	> UInt16					"defaultButton"
	> UInt16					"helpRscId"
	> UInt16					"menuRscId"
	> UInt16					"numObjects"
	> MemPtr					"objects"
	typeend
typedef FormType31 @"FormPtr31"

	
typedef struct "FormType"
	> WindowType			"window"
	> UInt16					"formId"
	> UInt32					"attr"
	> WinPtr					"bitsBehindForm"
	> MemPtr					"handler"
	> UInt16					"focus"
	> UInt16					"defaultButton"
	> UInt16					"helpRscId"
	> UInt16					"menuRscId"
	> UInt16					"numObjects"
	> MemPtr					"objects"
	typeend
typedef FormType @"FormPtr"

	
typedef struct "TP3Data"
	> MemPtr					"privateP"
	> MemPtr					"glyphsP"
	> MemPtr					"dictionaryP"
	> MemPtr					"macrosP"
	typeend

typedef struct "TP3DictState"
	> UInt16					"lockFlags"
	> UInt8					"lastGlyph"
	> UInt8					"filler"
	> UInt16					"lastGlyphBranch"
	> UInt16					"top"
	> UInt16					"stack"[8] \-
	typeend
		
	
typedef struct "GrfGlobalsType"
	> TP3Data 				"p3Data"
	> TP3DictState 		"state"
	> Int16 					"uncertain"
	> UInt16 				"glyphFlags"
	> UInt16 				"shiftState"
	
	> Int16 					"macroNameLen"
	> UInt8 					"macroName"[#32] \-
	> UInt8 					"lastChar"
	
	> UInt32 				"globalsSize"
	> UInt16					"flags"
	> UInt8 					"upShiftGlyphID"
	> MemHandle 			"globalsH"
	> MemHandle				"templateH"
	> MemHandle 			"dictH"
	> MemHandle 			"macrosH"
	> DmAccessPtr 			"macrosDbP"
	typeend
	
typedef struct "FtrGlobalsType"
	> MemHandle				"romTableH"
	> MemHandle				"ramTableH"
	typeend
	

typedef struct "ScrBltInfoType"
	> UInt8 					"op"
	> Int16 					"height"
	> UInt16Ptr				"dstBaseP"
	> UInt16 				"dstRowBytes"
	> UInt16Ptr 			"srcBaseP"
	> UInt16 				"srcRowBytes"
	> UInt16 				"leftMask"
	> UInt16					"rightMask"
	> Int16 					"midWords"
	> Int16 					"dstRowDelta"
	> UInt16Ptr 			"dstP"
	> Int16 					"srcRowDelta"
	> UInt16Ptr 			"srcP"
	> UInt16Ptr				"patternP"
	> UInt16 				"solidPat"
	> Boolean 				"simple"
	> UInt16 				"pattern"[4]
	typeend
typedef ScrBltInfoType  @"ScrBltInfoPtr"


typedef struct "LineInfoType"
	> UInt16					"start"
	> UInt16					"length"
	typeend
typedef LineInfoType @"LineInfoPtr"

typedef struct "FieldType"
	> UInt16					"id"
	> RectangleType		"rect"
	> UInt16					"attr"
	> CharPtr				"text"
	> MemHandle				"textHandle"
	> LineInfoPtr			"lines"
	> UInt16					"textLen"
	> UInt16					"textBlockSize"
	> UInt16					"maxChars"
	> UInt16					"selFirstPos"
	> UInt16					"selLastPos"
	> UInt16					"insPtXPos"
	> UInt16					"insPtYPos"
	> UInt8					"fontID"
	> UInt8					"__filler"
	typeend
typedef FieldType @"FieldPtr"

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ShiftJIS Extension data structures
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

typedef struct "IntlGlobalsType"
	> MemPtr					"charAttrP"
	> MemPtr					"charXAttrP"
	> UInt8Ptr				"byteAttrP"
	> MemPtr					"searchTableP"
	> MemPtr					"upperCaseMapP"
	> MemPtr					"lowerCaseMapP"
	> MemPtr					"fullToHalfKatakanaMapP"
	> MemPtr					"halfToFullKatakanaMapP"
	> MemPtr					"fullToHalfRomajiMapP"
	> MemPtr					"halfToFullRomajiMapP"
	> MemPtr					"katakanaToHiraganaMapP"
	> MemPtr					"hiraganaToKatakanaMapP"
	> MemPtr					"combineSoundMarkMapP"
	> MemPtr					"divideSoundMarkMapP"
	> MemPtr					"romajiToHiraganaTableP"
	> MemPtr					"hiraganaToRomajiTableP"
	> MemPtr					"addWordMenuItemTextP"
	> MemPtr					"lookupWordMenuItemTextP"
	> MemPtr					"errDisplayRoutineP"
	> UInt16					"dbCard"
	> LocalID				"dbID"
	typeend
typedef IntlGlobalsType @"IntlGlobalsPtr"

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; FEP (input method) data structures
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

typedef struct "TsmFepStatusType"
	> UInt16					"refnum"
	> CharPtr				"inlineText"
	> UInt16					"convertedLen"
	> UInt16					"pendingLen"
	> UInt16					"selectStart"
	> UInt16					"selectEnd"
	> UInt16					"convertStart"
	> UInt16					"convertEnd"
	typeend
typedef TsmFepStatusType @"TsmFepStatusPtr"

typedef struct "TsmFepEventType"
	> Int16					"penOffset"
	> Boolean				"penLeading"
	> Boolean				"formEvent"
	> UInt16					"maxInline"
	> CharPtr				"primeText"
	> UInt16					"primeOffset"
	> UInt16					"primeLen"
	typeend
typedef TsmFepEventType @"TsmFepEventPtr"

typedef struct "TsmFepActionType"
	> UInt16					"dumpLength"
	> UInt16					"primedLength"
	> Boolean				"updateText"
	> Boolean				"updateSelection"
	> Boolean				"updateFepMode"
	> Boolean				"handledEvent"
	typeend
typedef TsmFepActionType @"TsmFepActionPtr"


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Various event types
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

typedef struct "KeyDownEventType"
	> UInt16	      "eType"
	> Boolean         "penDown"
	> UInt8           "tapCount"
	> Int16           "screenX"
	> Int16           "screenY"
	> WChar           "chr"
	> UInt16          "keyCode"
	> UInt16          "modifiers"
	typeend
typedef KeyDownEventType @"KeyDownEventPtr"


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; USB Globals
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

typedef struct "UsbDeviceRequestType"
	> UInt8					"bmRequestType"
	> UInt8					"bRequest"
	> UInt16				"wValue"
	> UInt16				"wIndex"
	> UInt16				"wLength"
	typeend

typedef struct "UsbConfigurationType"
	> UInt8					"configuration"
	> UInt8					"flags"
	> UInt16				"reserved"
	typeend
typedef UsbConfigurationType  @"UsbConfigurationPtr"

typedef struct "UsbControlBufferType"
	> UInt16				"length"
	> UInt16				"count"
	> UInt8					@"dataP"
	typeend

typedef struct "UsbQueueType"
	> UInt32          "qStart"		
	> UInt32          "qEnd"			
	> UInt32          "qSize"		
	> UInt8           @"qData"		
	> UInt8           @"qDefData"		
	typeend

typedef struct "UsbPortInfoType"
	> UsbQueueType    "transmit"			
	> DrvrHWRcvQPtr	  "receiveP"			

	> MemPtr          "wakeupHandler"		
	> UInt32          "wakeupRefcon"		

	> UInt16          "smSignalSendSize"	
										
	> UInt16          "smSignalReceiveSize"
										

	> UInt32          "lastRcvTicks"		
	> UInt32          "lastSendTicks"		

	> UInt16          "portFlags"

	> UInt8           "functionID"
	typeend
typedef UsbPortInfoType	  @"UsbPortInfoPtr"

typedef struct "UsbDebugInfoType"
	> UInt16          "busReset"			
	> UInt16          "controlTransmit"	
	> UInt16          "controlReceive"	
	> UInt16          "mainTransmit"		
	> UInt16          "mainReceive"		
	> UInt16          "suspend"			
	typeend


var 	"usbMaxPorts"						 #2
var 	"usbHwrEndpointMaxPacketSize"		#64

typedef struct "UsbGlobalsType"
	> UInt16				"openCount"
	> Int16					"port"
	> UInt16				"lineErrors"

	> UInt8					"controlState"
	> UInt8					"filler"
	> UInt16				"flags"
	> UsbDeviceRequestType	"request"
	> UsbConfigurationPtr	"configP"

	> UsbControlBufferType	"cntlReceive"
	> UsbControlBufferType	"cntlTransmit"

	> UInt32				"smID"
	> MemPtr				"oldIntHandler"

	> UsbPortInfoPtr		"portInfoP"[usbMaxPorts]
	> UsbPortInfoType		"portInfo"[usbMaxPorts]

	> UInt8					"tempBuf"[usbHwrEndpointMaxPacketSize]
	> UInt16				"intErrors"

	> UsbDebugInfoType		"debugInfo"
	typeend




;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Globals/UIGlobals from 2.0 devices
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

typedef struct "UIGlobalsTypeV20" 
	> WinHandle 			"activeWindow"
	> WinHandle 			"displayWindow"
	> WinHandle 			"drawWindow"
	> WinHandle 			"firstWindow"
	> WinHandle 			"exitWindowID"
	> WinHandle 			"enterWindowID"
	> WinHandle 			"exitedWindowID"
	> GraphicStateTypeV20 "gState"
	> MemPtr					"eventQ"
	> UInt16 				"eventQIndex"
	> UInt16 				"eventQLength"
	> Int16 					"lastScreenX"
	> Int16 					"lastScreenY"
	> Boolean 				"lastPenDown"
	> Int32 					"needNullTickCount"
	> MemPtr 				"uiCurrentFontPtr"
	> MemPtr 				"uiFontTable"[7]
	> UInt8 					"uiCurrentFontID"
	> MemPtr	 				"currentForm"
	> Boolean				"insPtIsEnabled"
	> Boolean 				"insPtOn"
	> PointType 			"insPtLoc"
	> Int16 					"insPtHeight"
	> Int32					"insPtLastTick"
	> WinHandle	 			"insPtBitsBehind"
	> ClipboardItem 		"clipboard"[3]
	> MemPtr		 			"uiCurrentMenu"
	> FieldUndoType 		"undoGlobals"
	> UInt8 					"gsiState"
	> Boolean 				"gsiIsEnabled"
	> PointType 			"gsiLocation"
	typeend
typedef UIGlobalsTypeV20	@"UIGlobalsPtrV20"


typedef struct "GlobalsTypeV20" 
	> UInt8					"memCardSlots"
	> UInt8					"dbgWasEntered"
	> CardInfoPtr			"memCardInfoP"
	> UInt32					"memSemaphoreID"
	> UInt16					"memDebugMode"
	
	> DmOpenInfoPtr		"dmOpenList"
	
	> UInt8 					"dbgInDebugger"
	> UInt8 					"dbgTracing"
	> MemPtr					"dbgGlobalsP"
	> MemPtr					"dbgSerGlobalsP"
	
	> SysAppInfoPtr		"sysAppInfoP"
	> MemPtr					"sysKernelDataP"
	> MemPtr					"sysDispatchTableP"	
	> UInt32					"sysOwnerIDsInUse"				
	> MemPtr					"sysAMXAppInfoP"
	> UInt32					"sysClockFreq"
	> UInt32Ptr				"sysHardKeyCreators"
	
	> Int16					"sysBatteryCheckTimer"
	> UInt8					"sysBatteryMinThreshold"
	> UInt8					"sysBatteryLevel"
	> Int16					"sysNextBatteryTimer"
	> UInt8					"sysBatteryWarnThreshold"
	
	> UInt8					"sysDispatchTableRev"
	> UInt16					"sysDispatchTableSize"
	
	> SysLibTblEntryPtr	"sysLibTableP"
	> UInt16					"sysLibTableEntries"
	> MemPtr					"sysConsoleStackChunkP"
	> SysAppInfoPtr		"sysUIShellAppInfoP"
	
	> Int32					"sysTimerID"
	> UInt32					"sysAutoOffEvtTicks"
	> UInt16					"sysAutoOffSeconds"
	> Int32					"sysRandomSeed"
	
	> MemPtr					"slkGlobalsP"
	> MemPtr			 		"serGlobalsP"
	> MemPtr					"scrGlobalsP"
	> MemPtr					"fplGlobalsP"
	> MemPtr					"penGlobalsP"
	> MemPtr					"sysEvtMgrGlobalsP"
	> MemPtr					"sndGlobalsP"
	> MemPtr					"timGlobalsP"
	> MemPtr					"almGlobalsP"
	> MemPtr					"ftrGlobalsP"
	> MemPtr					"grfGlobalsP"
	> MemPtr					"keyGlobalsP"
	
	> UInt8					"uiGlobals"[$B0] \-
	> MemPtr					"uiExtensionsP"
	
	> SysAppInfoPtr		"curUIAppInfoP"
	> UInt32					"nextUIAppDBID"
	> UInt16					"nextUIAppCmd"
	> MemPtr					"nextUIAppCmdPBP"
	> UInt8					"nextUIAppCardNo"
	
	
	> Int8					"memDataWELevel"
	> UInt16					"hwrWakeUp"
	> UInt8					"hwrCPUDutyCycle"
	> UInt8					"hwrPenDown"
	> UInt32					"hwrCurTicks"
	> UInt32					"hwrTotalRAMSize"
	> UInt32					"hwrDozeSubTicks"
	
	> UInt32					"sndOffTicks"
	> UInt8					"sysResetFlags"
	> UInt8					"sysBatteryKind"
	
	> UInt32					"memMinDynHeapFree"
	
	> UInt16					"sysPrefFlags"
	
	> MemPtr					"sysGlobalsP"
	
	> UInt16					"sysMiscFlags"
	
	> UInt16					"sysLibNet"
	> MemPtr					"netPktFreeQ"
	
	> UInt32					"sysEvGroupID"

	> MemPtr					"irq3GlobalsP"
	
	> UInt32					"sysLastBatteryWarning"
	> UInt32					"sysLowMemChecksum"
	
	> UInt16					"hwrHardwareRev"
	
	> MemHandle				"dmProtectListH"
	> UInt16					"hwrMiscFlags"
	
	> UInt32					"sysProfilerRefcon"
	> MemPtr					"sysProfilerProcP"
	
	> UInt32					"flpSoftFPSCR"

	typeend


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Globals/UIGlobals from 3.0 device
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

typedef struct "UIGlobalsType" 
	> WinHandle 			"activeWindow"
	> WinHandle 			"displayWindow"
	> WinHandle 			"drawWindow"
	> WinHandle 			"firstWindow"
	> WinHandle 			"exitWindowID"
	> WinHandle 			"enterWindowID"
	> WinHandle 			"exitedWindowID"
	> GraphicStateType 	"gState"
	> MemPtr					"eventQ"
	> UInt16 				"eventQIndex"
	> UInt16 				"eventQLength"
	> Int16 					"lastScreenX"
	> Int16 					"lastScreenY"
	> Boolean 				"lastPenDown"
	> Int32 					"needNullTickCount"
	> MemPtr 					"uiCurrentFontPtr"
	> MemPtr					"uiSysFontTablePtr"
	> MemPtr					"uiAppFontTablePtr"
	> UInt16					"uiNumSysFonts"
	> UInt16					"uiNumAppFonts"
	> UInt32					"uiReserved"[2] \-
	> UInt8 					"uiCurrentFontID"
	> MemPtr	 				"currentForm"
	> Boolean				"insPtIsEnabled"
	> Boolean 				"insPtOn"
	> PointType 			"insPtLoc"
	> Int16 					"insPtHeight"
	> Int32					"insPtLastTick"
	> WinHandle				"insPtBitsBehind"
	> ClipboardItem 		"clipboard"[3]
	> MemPtr		 			"uiCurrentMenu"
	> FieldUndoType 		"undoGlobals"
	> UInt8 					"gsiState"
	> Boolean 				"gsiIsEnabled"
	> PointType 			"gsiLocation"
	typeend
typedef UIGlobalsType	@"UIGlobalsPtr"


typedef struct "GlobalsType" 
	> UInt8					"memCardSlots"
	> UInt8					"dbgWasEntered"
	> CardInfoPtr			"memCardInfoP"
	> UInt32					"memSemaphoreID"
	> UInt16					"memDebugMode"
	
	> DmOpenInfoPtr		"dmOpenList"
	
	> UInt8 					"dbgInDebugger"
	> UInt8 					"dbgTracing"
	> MemPtr					"dbgGlobalsP"
	> MemPtr					"dbgSerGlobalsP"
	
	> SysAppInfoPtr		"sysAppInfoP"
	> MemPtr					"sysKernelDataP"
	> MemPtr					"sysDispatchTableP"	
	> UInt32					"sysOwnerIDsInUse"				
	> MemPtr					"sysAMXAppInfoP"
	> UInt32					"sysClockFreq"
	> UInt32Ptr				"sysHardKeyCreators"
	
	> Int16					"sysBatteryCheckTimer"
	> UInt8					"sysBatteryMinThreshold"
	> UInt8					"hwrBatteryLevel"
	> Int16					"sysNextBatteryAlertTimer"
	> UInt8					"sysBatteryWarnThreshold"
	
	> UInt8					"sysDispatchTableRev"
	> UInt16					"sysDispatchTableSize"
	
	> SysLibTblEntryPtr	"sysLibTableP"
	> UInt16					"sysLibTableEntries"
	> MemPtr					"sysConsoleStackChunkP"
	> SysAppInfoPtr		"sysUIShellAppInfoP"
	
	> Int32					"sysTimerID"
	> UInt32					"sysAutoOffEvtTicks"
	> UInt16					"sysAutoOffSeconds"
	> Int32					"sysRandomSeed"
	
	> MemPtr					"slkGlobalsP"
	> MemPtr			 		"serGlobalsP"
	> MemPtr					"scrGlobalsP"
	> MemPtr					"fplGlobalsP"
	> MemPtr					"penGlobalsP"
	> MemPtr					"sysEvtMgrGlobalsP"
	> MemPtr					"sndGlobalsP"
	> MemPtr					"timGlobalsP"
	> MemPtr					"almGlobalsP"
	> MemPtr					"ftrGlobalsP"
	> MemPtr					"grfGlobalsP"
	> MemPtr					"keyGlobalsP"
	
	> UInt8					"uiGlobals"[$B0] \-
	> MemPtr					"uiExtensionsP"
	
	> SysAppInfoPtr		"curUIAppInfoP"
	> UInt32					"nextUIAppDBID"
	> UInt16					"nextUIAppCmd"
	> MemPtr					"nextUIAppCmdPBP"
	> UInt8					"nextUIAppCardNo"
	
	
	> Int8					"memDataWELevel"
	> UInt16					"hwrWakeUp"
	> UInt8					"hwrCPUDutyCycle"
	> UInt8					"hwrPenDown"
	> UInt32					"hwrCurTicks"
	> UInt32					"hwrTotalRAMSize"
	> UInt32					"hwrDozeSubTicks"
	
	> UInt32					"sndOffTicks"
	> UInt8					"sysResetFlags"
	> UInt8					"sysBatteryKind"
	
	> UInt32					"memMinDynHeapFree"
	
	> UInt16					"sysPrefFlags"
	
	> MemPtr					"sysGlobalsP"
	
	> UInt16					"sysMiscFlags"
	
	> UInt16					"sysLibNet"
	> MemPtr					"netPktFreeQ"
	
	> UInt32					"sysEvGroupID"

	> MemPtr					"irq3GlobalsP"
	
	> UInt32					"sysLastBatteryWarning"
	> UInt32					"sysLowMemChecksum"
	
	> UInt16					"hwrHardwareRev"
	
	> MemHandle				"dmProtectListH"
	> UInt16					"hwrMiscFlags"
	
	> UInt32					"sysProfilerRefcon"
	> MemPtr					"sysProfilerProcP"
	
	> UInt32					"flpSoftFPSCR"
	
	> MemPtr					"irLibGlobalsP"
	> UInt16					"exgActiveLib"
	> UInt16					"uiBusyCount"
	> MemPtr					"irq1GlobalsP"
	> MemPtr					"irq2GlobalsP"
	> MemPtr					"irq6GlobalsP"

	> MemPtr					"intlMgrGlobalsP"

	> UInt16					"inlineStart"						
	> UInt16					"inlineEnd"						
	> Boolean				"inlineActive"			
	> UInt8					"inlineDefTerm"			
	> VoidPtr				"tsmFepLibStatusP"
	> UInt16					"tsmFepLibRefNum"						
	> UInt16					"inlineHighlightLen"			

	> MemPtr					"sysBatteryDataP"
	> MemPtr					"sysBatteryValidKindsP"
	
	> Boolean				"sysInShutdown"		
	> UInt8					"sysMinWakeupThreshold"
	
	> UInt32					"hwrMiscFlagsExt"

	> Boolean				"sysUseCritWarnTimer"
	> Boolean				"sysCritWarnTimerRunning"
	> Int16					"sysCritWarnRTCDayStarted"
	> Int32					"sysCritWarnTickTimer"
	> UInt32					"sysCritWarnLastTick"
	> Boolean				"sysCharging"
	> Boolean				"sysUpdateVoltageLevel"

	> MemHandle				"notifyGlobalsH"

	> UInt32					"sysReserved31DWord1"
	> UInt32					"sysReserved31DWord2"
	> UInt32					"sysReserved31DWord3"
	> UInt32					"sysReserved31DWord4"

	> MemPtr					"ramGlobalsP"
	> MemPtr					"hwrBatteryGlobalsP"
	> UInt8					"hwrBatteryPercent"
	> UInt8					"commActivityFlags"

	> MemPtr					"uart328GlobalsP"

	> UInt32					"sysOEMGlobal1"
	> UInt32					"sysOEMGlobal2"

	> UInt16					"hwrBatteryStepsPerVolt"
	
	> MemPtr					"sysPendingStackFrees"
	> UInt16					"sysDayCounter"
	> UInt16					"sysBatteryCheckPeriod"						

	> UInt16					"hwrJerryPldShadow"						

	> Ptr						"radioGlobalsP"

	> Ptr						"fatalAlertTemplateP"
	> UInt16					"fatalAlertBtnWidth"
	
	> Ptr						"silkscreenInfoP"

	> UInt16					"inlineDefChecksum"
	> Ptr						"inlineDefField"

	> Boolean				"notifyBroadcastPending"
	> UInt8					"unused"
	
	> UInt32					"hwrOEMCompanyID"
	> UInt32					"hwrOEMDeviceID"
	> UInt32					"hwrOEMHALID"
	
	> Ptr						"sysUpdateGlobalsP"
	> UInt16					"smallROMChecksum"
	typeend
	
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; LowMem structures from 2.0 devices
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

var 	"hwrNumCardSlots"			#1

typedef struct "LowMemTypeV20"
	> M68KExcTableType		"vectors" \-
	> GlobalsTypeV20			"globals"
	> CardInfoType				"memCardInfo"[hwrNumCardSlots]
	> SlkGlobalsType			"slkGlobals" \-
	> DbgGlobalsType			"dbgGlobals" \-
	> SysAppInfoType			"sysAppInfo" \-
	> MemPtr						"sysDispatchTable"[2]
	typeend
	
	

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; LowMem structures from 3.0 device
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

typedef struct "LowMemHdrType"
	> M68KExcTableType		"vectors"
	> GlobalsType				"globals"
	typeend
	
typedef struct "LowMemType"
	> M68KExcTableType		"vectors" \-
	> GlobalsType				"globals"
	> CardInfoType				"memCardInfo"[hwrNumCardSlots]
	> SlkGlobalsType			"slkGlobals" \-
	> DbgGlobalsType			"dbgGlobals" \-
	> SysAppInfoType			"sysAppInfo" \-
	> MemPtr					"sysDispatchTable"[2]
	typeend
	
typedef struct "MemHeapHeaderType"
	>UInt16		"flags"
	>UInt32		"size"
	>UInt32		"freeSearchStartOffset";	// offset/2 to first free chunk
	>UInt16		"numEntries";					// number of master pointer entries
	>UInt32		"nextTblOffset";				// offset from start of heap to next table
	typeend


typedef struct "MemChunkHeaderType"
	>UInt8		"free/moved/unused/unused/sizeAdj(4)"\%
	>UInt8		"size"[3]
	>UInt8		"lockCount(4)owner(4)"\%
	>UInt8		"ownerOffset(s24)"[3]
	typeend
	

typedef struct "MemChunkHeaderTypeArm"
	>UInt8		"size incl header (little)"[3]
	>UInt8		"free/moved/offsetLSB(2)/sizeAdj(4)"\%
	>UInt8		"ownerOffsetMSB (little)"[3]
	>UInt8		"lockCount(4)owner(4)"\%
	typeend


;################################################################
; Macros
;##############################################################
alias "LowMem" 		"dm 0 LowMemType"
alias "LowMemV20" 	"dm 0 LowMemTypeV20"

alias "M68KExcTable" "dm 0 M68KExcTableType"
alias "Globals" 		"dm 100 GlobalsType"
alias "GlobalsV20"	"dm 100 GlobalsTypeV20"
alias "UIGlobals" 	"dm 18c UIGlobalsType"
alias "UIGlobalsV20" "dm 18c UIGlobalsTypeV20"

alias "SlkGlobals"	"dm 2dc SlkGlobalsType"
alias "DbgGlobals"	"dm 318 DbgGlobalsType"
alias "SysAppInfo"	"dm 6e6 SysAppInfoType"

; There's already a (slightly outdated) debugger command for this...
;alias "CardInfo"		"dm 2b0 CardInfoType"

alias "SysLibTbl"		"dw 00144 \n dm @00140 SysLibTblEntryType"

alias "ScrGlobals"		"dm @.l($00000164) ScrGlobalsType"
alias "Ser328Globals"	"dm @.l($00000160) SerGlobalsType"
alias "Ser681Globals"	"dm @.l($0000027C) Ser681GlobalsType"

;alias "NewROM"    	"load \"fakerom\" 20000 \n g @(.+4)"
;alias "NewROM1"   	"load \"fakerom\" 820000 \n g @(.+4)"

alias "UsbGlobals" 		"dm @.l($0000027C) UsbGlobalsType"
alias "SrmGlobals" 		"dm @.l($00000160) SrmGlobalsType"

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Aliases for displaying the alarm table
;;
;; Alias name: AlmGlobalsV30		-- displays the alarm table for PalmOS v1.0-3.0
;; Alias name: AlmGlobals			-- displays the alarm table for the current PalmOS version
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ASSUMPTIONS:
; almGlobalsP is at $0000017C
; alarm table addr = @.a((@.a(@.a$0000017C))&$7fffffff)
; number of alarm table entries is @.w(alarm table addr)
; the first alarm entry is at (alarm table addr)+2
;
;; NOTES:
; executing the alias AlmGlobals or AlmGlobalsV30 will generate the warning:
; "WARNING: redefining variable: _AlmTabP"
; ignore it.
alias "AlmGlobalsV30" "var \"_AlmTabP\" @.a((@.a(@.a$0000017C))&$7fffffff) \n dm @.a$0000017C AlmGlobalsTypeV30 \n dm _AlmTabP AlmTableType \n dm _AlmTabP+2  @.w(_AlmTabP) AlmEntryTypeV30"
alias "AlmGlobals" "var \"_AlmTabP\" @.a((@.a(@.a$0000017C))&$7fffffff) \n dm @.a$0000017C AlmGlobalsType \n dm _AlmTabP AlmTableType \n dm _AlmTabP+2  @.w(_AlmTabP) AlmEntryType"

